home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 2
/
Atari Mega Archive CD - Volume 2.iso
/
minix
/
up1510b.tgz
/
up1510b
/
doc
/
zmodem.doc
< prev
Wrap
Text File
|
1990-07-19
|
73KB
|
2,377 lines
- 1 -
XMODEM/YMODEM PROTOCOL REFERENCE
A compendium of documents describing the
XMODEM and YMODEM
File Transfer Protocols
Following the protocol description are the man pages
This document was formatted 9-11-86.
Edited by Chuck Forsberg
Please distribute as widely as possible.
Questions to Chuck Forsberg
Omen Technology Inc
17505-V Sauvie Island Road
Portland Oregon 97231
Voice: 503-621-3406
Modem (Telegodzilla): 503-621-3746 Speed 1200,300
Compuserve: 70007,2304
UUCP: ...!tektronix!reed!omen!caf
- 2 -
1. ROSETTA STONE
Here are some definitions which reflect the current vernacular in the
computer media. The attempt here is identify the file transfer protocol
rather than specific programs.
XMODEM refers to the original 1979 file transfer etiquette introduced by
Ward Christensen's 1979 MODEM2 program. It's also called the
MODEM or MODEM2 protocol. Some who are unaware of MODEM7's
unusual batch file mode call it MODEM7. Other aliases include
"CP/M Users's Group" and "TERM II FTP 3". This protocol is
supported by every serious communications program because of its
universality, simplicity, and reasonable performance.
XMODEM/CRC replaces XMODEM's 1 byte checksum with a two byte Cyclical
Redundancy Check (CRC-16), giving modern error detection
protection.
XMODEM-1k Refers to the XMODEM/CRC protocol with 1024 byte data blocks.
YMODEM refers to the XMODEM/CRC (optional 1k blocks) protocol with the
batch transmission described below.
ZMODEM uses familiar XMODEM/CRC and YMODEM technology in a new protocol
that provides reliability, throughput, file management, and user
amenities appropriate to contemporary data communications.
2. YET ANOTHER PROTOCOL?
Since its development half a decade ago, the Ward Christensen modem
protocol has enabled a wide variety of computer systems to interchange
data. There is hardly a communications program that doesn't at least
claim to support this protocol.
Recent advances in computing, modems and networking have revealed a number
of weaknesses in the original protocol:
+ The short block length caused throughput to suffer when used with
timesharing systems, packet switched networks, satellite circuits,
and buffered (error correcting) modems.
+ The 8 bit arithmetic checksum and other aspects allowed line
impairments to interfere with dependable, accurate transfers.
+ Only one file could be sent per command. The file name had to be
given twice, first to the sending program and then again to the
receiving program.
+ The transmitted file could accumulate as many as 127 extraneous
bytes.
Chapter 2
X/YMODEM Protocol Reference 09-11-86 3
+ The modification date of the file was lost.
A number of other protocols have been developed over the years, but none
have displaced XMODEM to date:
+ Lack of public domain documentation and example programs have kept
proprietary protocols such as MNP, Blast, and others tightly bound to
the fortunes of their suppliers.
+ Complexity discourages the widespread application of BISYNC, SDLC,
HDLC, X.25, and X.PC protocols.
+ Performance compromises and moderate complexity have limited the
popularity of the Kermit protocol, which was developed to allow file
transfers in environments hostile to XMODEM.
The XMODEM protocol extensions and YMODEM Batch address these weaknesses
while maintaining XMODEM's simplicity.
YMODEM is supported by the public domain programs YAM (CP/M),
YAM(CP/M-86), YAM(CCPM-86), IMP (CP/M), KMD (CP/M), rz/sz (Unix, Xenix,
VMS, Berkeley Unix, Venix, Xenix, Coherent, IDRIS, Regulus). Commerical
implementations include MIRROR, and Professional-YAM.[1] Communications
programs supporting these extensions have been in use since 1981.
The 1k packet length (XMODEM-1k) described below may be used in
conjunction with YMODEM Batch Protocol, or with single file transfers
identical to the XMODEM/CRC protocol except for minimal changes to support
1k packets.
Another extension is simply called the g option. It provides maximum
throughput when used with end to end error correcting media, such as X.PC
and error correcting modems, including the emerging 9600 bps units by
Electronic Vaults and others.
To complete this tome, Ward Christensen's original protocol document and
John Byrns's CRC-16 document are included for reference.
References to the MODEM or MODEM7 protocol have been changed to XMODEM to
accommodate the vernacular. In Australia, it is properly called the
Christensen Protocol.
__________
1. Available for IBM PC,XT,AT, Unix and Xenix
Chapter 2
X/YMODEM Protocol Reference 09-11-86 4
2.1 Some Messages from the Pioneer
#: 130940 S0/Communications 25-Apr-85 18:38:47
Sb: my protocol
Fm: Ward Christensen 76703,302 (EDITED)
To: all
Be aware the article[2] DID quote me correctly in terms of the phrases
like "not robust", etc.
It was a quick hack I threw together, very unplanned (like everything I
do), to satisfy a personal need to communicate with "some other" people.
ONLY the fact that it was done in 8/77, and that I put it in the public
domain immediately, made it become the standard that it is.
I think its time for me to
(1) document it; (people call me and say "my product is going to include
it - what can I 'reference'", or "I'm writing a paper on it, what do I put
in the bibliography") and
(2) propose an "incremental extension" to it, which might take "exactly"
the form of Chuck Forsberg's YAM protocol. He wrote YAM in C for CP/M and
put it in the public domain, and wrote a batch protocol for Unix[3] called
rb and sb (receive batch, send batch), which was basically XMODEM with
(a) a record 0 containing filename date time and size
(b) a 1K block size option
(c) CRC-16.
He did some clever programming to detect false ACK or EOT, but basically
left them the same.
People who suggest I make SIGNIFICANT changes to the protocol, such as
"full duplex", "multiple outstanding blocks", "multiple destinations", etc
etc don't understand that the incredible simplicity of the protocol is one
of the reasons it survived to this day in as many machines and programs as
it may be found in!
Consider the PC-NET group back in '77 or so - documenting to beat the band
- THEY had a protocol, but it was "extremely complex", because it tried to
be "all things to all people" - i.e. send binary files on a 7-bit system,
etc. I was not that "benevolent". I (emphasize > I < ) had an 8-bit UART,
__________
2. Infoworld April 29 p. 16
3. VAX/VMS versions of these programs are also available.
Chapter 2
X/YMODEM Protocol Reference 09-11-86 5
so "my protocol was an 8-bit protocol", and I would just say "sorry" to
people who were held back by 7-bit limitations. ...
Block size: Chuck Forsberg created an extension of my protocol, called
YAM, which is also supported via his public domain programs for UNIX
called rb and sb - receive batch and send batch. They cleverly send a
"block 0" which contains the filename, date, time, and size.
Unfortunately, its UNIX style, and is a bit weird[4] - octal numbers, etc.
BUT, it is a nice way to overcome the kludgy "echo the chars of the name"
introduced with MODEM7. Further, chuck uses CRC-16 and optional 1K
blocks. Thus the record 0, 1K, and CRC, make it a "pretty slick new
protocol" which is not significantly different from my own.
Also, there is a catchy name - YMODEM. That means to some that it is the
"next thing after XMODEM", and to others that it is the Y(am)MODEM
protocol. I don't want to emphasize that too much - out of fear that
other mfgrs might think it is a "competitive" protocol, rather than an
"unaffiliated" protocol. Chuck is currently selling a much-enhanced
version of his CP/M-80 C program YAM, calling it Professional Yam, and its
for the PC - I'm using it right now. VERY slick! 32K capture buffer,
script, scrolling, previously captured text search, plus built-in commands
for just about everything - directory (sorted every which way), XMODEM,
YMODEM, KERMIT, and ASCII file upload/download, etc. You can program it
to "behave" with most any system - for example when trying a number for
CIS it detects the "busy" string back from the modem and substitutes a
diff phone # into the dialing string and branches back to try it.
3. XMODEM PROTOCOL ENHANCEMENTS
This chapter discusses the protocol extensions to Ward Christensen's 1982
XMODEM protocol description document.
The original document recommends the user be asked whether to continue
trying or abort after 10 retries. Most programs no longer ask the
operator whether he wishes to keep retrying. Virtually all correctable
errors are corrected within the first few retransmissions. If the line is
so bad that ten attempts are insufficient, there is a significant danger
of undetected errors. If the connection is that bad, it's better to
redial for a better connection, or mail a floppy disk.
__________
4. The file length, time, and file mode are optional. The pathname and
file length may be sent alone if desired.
Chapter 3 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 09-11-86 6
3.1 Graceful Abort
The YAM and Professional-YAM X/YMODEM routines recognize a sequence of two
consecutive CAN (Hex 18) characters without modem errors (overrun,
framing, etc.) as a transfer abort command. This sequence is recognized
when YAM is waiting for the beginning of a packet or for an acknowledge to
one that has been sent. The check for two consecutive CAN characters
virtually eliminates the possibility of a line hit aborting the transfer.
YAM sends eight CAN characters when it aborts an XMODEM, YMODEM, or ZMODEM
protocol file transfer. Pro-YAM then sends eight backspaces to delete the
CAN characters from the remote's keyboard input buffer, in case the remote
had already aborted the transfer and was awaiting a keyboarded command.
3.2 CRC-16 Option
The XMODEM protocol uses an optional two character CRC-16 instead of the
one character arithmetic checksum used by the original protocol and by
most commercial implementations. CRC-16 guarantees detection of all
single and double bit errors, all errors with an odd number of error
bits, all burst errors of length 16 or less, 99.9969% of all 17-bit error
bursts, and 99.9984 per cent of all possible longer error bursts. By
contrast, a double bit error, or a burst error of 9 bits or more can sneak
past the XMODEM protocol arithmetic checksum.
The XMODEM/CRC protocol is similar to the XMODEM protocol, except that the
receiver specifies CRC-16 by sending C (Hex 43) instead of NAK when
requesting the FIRST packet. A two byte CRC is sent in place of the one
byte arithmetic checksum.
YAM's c option to the r command enables CRC-16 in single file reception,
corresponding to the original implementation in the MODEM7 series
programs. This remains the default because many commercial communications
programs and bulletin board systems still do not support CRC-16,
especially those written in Basic or Pascal.
XMODEM protocol with CRC is accurate provided both sender and receiver
both report a successful transmission. The protocol is robust in the
presence of characters lost by buffer overloading on timesharing systems.
The single character ACK/NAK responses generated by the receiving program
adapt well to split speed modems, where the reverse channel is limited to
ten per cent or less of the main channel's speed.
XMODEM and YMODEM are half duplex protocols which do not attempt to
transmit information and control signals in both directions at the same
time. This avoids buffer overrun problems that have been reported by
users attempting to exploit full duplex asynchronous file transfer
protocols such as Blast.
Professional-YAM adds several proprietary logic enhancements to XMODEM's
Chapter 3 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 09-11-86 7
error detection and recovery. These compatible enhancements eliminate
most of the bad file transfers other programs make when using the XMODEM
protocol under less than ideal conditions.
3.3 XMODEM-1k 1024 Byte Packet
The choice to use 1024 byte packets is expressed to the sending program on
its command line or selection menu.[1] 1024 byte packets improve
throughput in many applications, but some environments cannot accept 1024
byte bursts, especially minicomuters running 19.2kb ports.
An STX (02) replaces the SOH (01) at the beginning of the transmitted
block to notify the receiver of the longer packet length. The transmitted
packet contains 1024 bytes of data. The receiver should be able to accept
any mixture of 128 and 1024 byte packets. The packet number is
incremented by one for each packet regardless of the packet length.
The sender must not change between 128 and 1024 byte packet lengths if it
has not received a valid ACK for the current packet. Failure to observe
this restriction allows certain transmission errors to pass undetected.
If 1024 byte packets are being used, it is possible for a file to "grow"
up to the next multiple of 1024 bytes. This does not waste disk space if
the allocation granularity is 1k or greater. With YMODEM batch
transmission, the optional file length transmitted in the file name packet
allows the receiver to discard the padding, preserving the exact file
length and contents.
1024 byte packets may be used with batch file transmission or with single
file transmission. CRC-16 should be used with the k option to preserve
data integrity over phone lines. If a program wishes to enforce this
recommendation, it should cancel the transfer, then issue an informative
diagnostic message if the receiver requests checksum instead of CRC-16.
Under no circumstances may a sending program use CRC-16 unless the
receiver commands CRC-16.
4. YMODEM Batch File Transmission
The YMODEM Batch protocol is an extension to the XMODEM/CRC protocol that
allows 0 or more files to be transmitted with a single command. (Zero
files may be sent if none of the requested files is accessible.) The
design approach of the YMODEM Batch protocol is to use the normal routines
for sending and receiving XMODEM packets in a layered fashion similar to
__________
1. See "KMD/IMP Exceptions to YMODEM" below.
Chapter 4 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 09-11-86 8
Figure 1. 1024 byte Packets
SENDER RECEIVER
"s -k foo.bar"
"foo.bar open x.x minutes"
C
STX 01 FE Data[1024] CRC CRC
ACK
STX 02 FD Data[1024] CRC CRC
ACK
STX 03 FC Data[1000] CPMEOF[24] CRC CRC
ACK
EOT
ACK
Figure 2. Mixed 1024 and 128 byte Packets
SENDER RECEIVER
"s -k foo.bar"
"foo.bar open x.x minutes"
C
STX 01 FE Data[1024] CRC CRC
ACK
STX 02 FD Data[1024] CRC CRC
ACK
SOH 03 FC Data[128] CRC CRC
ACK
SOH 04 FB Data[100] CPMEOF[28] CRC CRC
ACK
EOT
ACK
packet switching methods.
Why was it necessary to design a new batch protocol when one already
existed in MODEM7?[1] The batch file mode used by MODEM7 is unsuitable
because it does not permit full pathnames, file length, file date, or
other attribute information to be transmitted. Such a restrictive design,
hastily implemented with only CP/M in mind, would not have permitted
extensions to current areas of personal computing such as Unix, DOS, and
object oriented systems. In addition, the MODEM7 batch file mode is
somewhat susceptible to transmission impairments.
__________
1. The MODEM7 batch protocol transmitted CP/M FCB bytes f1...f8 and
t1...t3 one character at a time. The receiver echoed these bytes as
received, one at a time.
Chapter 4 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 09-11-86 9
As in the case of single a file transfer, the receiver initiates batch
file transmission by sending a "C" character (for CRC-16).
The sender opens the first file and sends packet number 0 with the
following information.[2]
Only the pathname (file name) part is required for batch transfers.
To maintain upwards compatibility, all unused bytes in packet 0 must be
set to null.
Pathname The pathname (conventionally, the file name) is sent as a null
terminated ASCII string. This is the filename format used by the
handle oriented MSDOS(TM) functions and C library fopen functions.
An assembly language example follows:
DB 'foo.bar',0
No spaces are included in the pathname. Normally only the file name
stem (no directory prefix) is transmitted unless the sender has
selected YAM's f option to send the full pathname. The source drive
(A:, B:, etc.) is never sent.
Filename Considerations:
+ File names should be translated to lower case unless the sending
system supports upper/lower case file names. This is a
convenience for users of systems (such as Unix) which store
filenames in upper and lower case.
+ The receiver should accommodate file names in lower and upper
case.
+ When transmitting files between different operating systems,
file names must be acceptable to both the sender and receiving
operating systems.
If directories are included, they are delimited by /; i.e.,
"subdir/foo" is acceptable, "subdir\foo" is not.
Length The file length and each of the succeeding fields are optional.[3]
The length field is stored in the packet as a decimal string counting
the number of data bytes in the file. The file length does not
include any CPMEOF (^Z) or other garbage characters used to pad the
last packet.
__________
2. Only the data part of the packet is described here.
3. Fields may not be skipped.
Chapter 4 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 09-11-86 10
If the file being transmitted is growing during transmission, the
length field should be set to at least the final expected file
length, or not sent.
The receiver stores the specified number of characters, discarding
any padding added by the sender to fill up the last packet.
Modification Date The mod date is optional, and the filename and length
may be sent without requiring the mod date to be sent.
Iff the modification date is sent, a single space separates the
modification date from the file length.
The mod date is sent as an octal number giving the time the contents
of the file were last changed, measured in seconds from Jan 1 1970
Universal Coordinated Time (GMT). A date of 0 implies the
modification date is unknown and should be left as the date the file
is received.
This standard format was chosen to eliminate ambiguities arising from
transfers between different time zones.
Two Microsoft blunders complicate the use of modification dates in
file transfers with MSDOS(TM) systems. The first is the lack of
timezone standardization in MS-DOS. A file's creation time can not
be known unless the timezone of the system that wrote the file[4] is
known. Unix solved this problem (for planet Earth, anyway) by
stamping files with Universal Time (GMT). Microsoft would have to
include the timezone of origin in the directory entries, but does
not. Professional-YAM gets around this problem by using the z
parameter which is set to the number of minutes local time lags GMT.
For files known to originate from a different timezone, the -zT
option may be used to specify T as the timezone for an individual
file transfer.
The second problem is the lack of a separate file creation date in
DOS. Since some backup schemes used with DOS rely on the file
creation date to select files to be copied to the archive, back-
dating the file modification date could interfere with the safety of
the transferred files. For this reason, Pro-YAM does not modify the
date of received files with the header information unless the d
numeric parameter is non zero.
__________
4. Not necessarily that of the transmitting system!
Chapter 4 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 09-11-86 11
Mode Iff the file mode is sent, a single space separates the file mode
from the modification date. The file mode is stored as an octal
string. Unless the file originated from a Unix system, the file mode
is set to 0. rb(1) checks the file mode for the 0x8000 bit which
indicates a Unix type regular file. Files with the 0x8000 bit set
are assumed to have been sent from another Unix (or similar) system
which uses the same file conventions. Such files are not translated
in any way.
Serial Number Iff the serial number is sent, a single space separates the
serial number from the file mode. The serial number of the
transmitting program is stored as an octal string. Programs which do
not have a serial number should omit this field, or set it to 0. The
receiver's use of this field is optional.
Other Fields YMODEM was designed to allow additional header fields to be
added as above without creating compatibility problems with older
YMODEM programs. Please contact Omen Technology if other fields are
needed for special application requirements.
The rest of the packet is set to nulls. This is essential to preserve
upward compatibility.[5]
If the filename packet is received with a CRC or other error, a
restrnsmission is requested. After the filename packet has been received,
it is ACK'ed if the write open is successful. If the file cannot be
opened for writing, the receiver cancels the transfer with CAN characters
as described above.
The receiver then initiates transfer of the file contents according to the
standard XMODEM/CRC protocol.
After the file contents have been transmitted, the receiver again asks for
the next pathname. Transmission of a null pathname terminates batch file
transmission. Note that transmission of no files is not necessarily an
error. This is possible if none of the files requested of the sender
could be opened for reading.
In batch transmission, the receiver automatically requests CRC-16.
The Unix programs sz(1) and rz(1) included in the source code file
__________
5. If, perchance, this information extends beyond 128 bytes (possible
with Unix 4.2 BSD extended file names), the packet should be sent as a
1k packet as described above.
Chapter 4 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 09-11-86 12
RZSZ[12].SHQ (rzsz1.sh, rzsz2.sh) should answer other questions about
YMODEM batch protocol.
Figure 3. YMODEM Batch Transmission Session
SENDER RECEIVER
"sb foo.*<CR>"
"sending in batch mode etc."
C (command:rb)
SOH 00 FF foo.c NUL[123] CRC CRC
ACK
C
SOH 01 FE Data[128] CRC CRC
ACK
STX 02 FD Data[1024] CRC CRC
ACK
SOH 03 FC Data[128] CRC CRC
ACK
SOH 04 FB Data[100] CPMEOF[28] CRC CRC
ACK
EOT
NAK
EOT
ACK
C
SOH 00 FF NUL[128] CRC CRC
ACK
Figure 4. YMODEM Filename packet transmitted by sz
-rw-r--r-- 6347 Jun 17 1984 20:34 bbcsched.txt
00 0100FF62 62637363 6865642E 74787400 |...bbcsched.txt.|
10 36333437 20333331 34373432 35313320 |6347 3314742513 |
20 31303036 34340000 00000000 00000000 |100644..........|
30 00000000 00000000 00000000 00000000
80 000000CA 56
Chapter 4 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 09-11-86 13
Figure 5. YMODEM Header Information used by various programs
_____________________________________________________________________
| Program | Batch | Length | Date | Mode | S/N | 1k-Blk | g-Option |
|___________|_______|________|______|______|_____|________|__________|
|Unix rz/sz | yes | yes | yes | yes | no | yes | sb only |
|___________|_______|________|______|______|_____|________|__________|
|VMS rb/sb | yes | yes | no | no | no | yes | no |
|___________|_______|________|______|______|_____|________|__________|
|Pro-YAM | yes | yes | yes | no | yes | yes | yes |
|___________|_______|________|______|______|_____|________|__________|
|CP/M YAM | yes | no | no | no | no | yes | no |
|___________|_______|________|______|______|_____|________|__________|
|KMD/IMP | yes | ? | no | no | no | yes | no |
|___________|_______|________|______|______|_____|________|__________|
4.1 KMD/IMP Exceptions to YMODEM
KMD and IMP character sequence emitted by the receiver (CK) to
automatically trigger the use of 1024 byte packets as an alternative to
specifying this option on this command line. Although this two character
sequence works well on single process micros in direct communication,
timesharing systems and packet switched networks can separate the
successive characters by several seconds, rendering this method
unreliable.
Sending programs may detect the CK sequence if the operating enviornment
does not preclude reliable implementation.
Receiving programs should retain the option of sending the standard YMODEM
C (not CK) trigger with the standard 10 second timeout to insure
compatibility with newer forms of telecommunications technology.
5. YMODEM-g File Transmission
Developing technology is providing phone line data transmission at ever
higher speeds using very specialized techniques. These high speed modems,
as well as session protocols such as X.PC, provide high speed, error free
communications at the expense of considerably increased delay time.
This delay time is moderate compared to human interactions, but it
cripples the throughput of most error correcting protocols.
The g option to YMODEM has proven effective under these circumstances.
The g option is driven by the receiver, which initiates the batch transfer
by transmitting a G instead of C. When the sender recognizes the G, it
bypasses the usual wait for an ACK to each transmitted packet, sending
succeeding packets at full speed, subject to XOFF/XON or other flow
control exerted by the medium.
Chapter 5 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 09-11-86 14
The sender expects an inital G to initiate the transmission of a
particular file, and also expects an ACK on the EOT sent at the end of
each file. This synchronization allows the receiver time to open and
close files as necessary.
If an error is detected in a YMODEM-g transfer, the receiver aborts the
transfer with the multiple CAN abort sequence. The ZMODEM protocol should
be used in applications that require both streaming throughput and error
recovery.
Figure 6. YMODEM-g Transmission Session
SENDER RECEIVER
"sb foo.*<CR>"
"sending in batch mode etc..."
G (command:rb -g)
SOH 00 FF foo.c NUL[123] CRC CRC
G
SOH 01 FE Data[128] CRC CRC
STX 02 FD Data[1024] CRC CRC
SOH 03 FC Data[128] CRC CRC
SOH 04 FB Data[100] CPMEOF[28] CRC CRC
EOT
ACK
G
SOH 00 FF NUL[128] CRC CRC
6. XMODEM PROTOCOL OVERVIEW
8/9/82 by Ward Christensen.
I will maintain a master copy of this. Please pass on changes or
suggestions via CBBS/Chicago at (312) 545-8086, CBBS/CPMUG (312) 849-1132
or by voice at (312) 849-6279.
6.1 Definitions
<soh> 01H
<eot> 04H
<ack> 06H
<nak> 15H
<can> 18H
<C> 43H
Chapter 6 Xmodem Protocol Overview
X/YMODEM Protocol Reference 09-11-86 15
6.2 Transmission Medium Level Protocol
Asynchronous, 8 data bits, no parity, one stop bit.
The protocol imposes no restrictions on the contents of the data being
transmitted. No control characters are looked for in the 128-byte data
messages. Absolutely any kind of data may be sent - binary, ASCII, etc.
The protocol has not formally been adopted to a 7-bit environment for the
transmission of ASCII-only (or unpacked-hex) data , although it could be
simply by having both ends agree to AND the protocol-dependent data with
7F hex before validating it. I specifically am referring to the checksum,
and the block numbers and their ones- complement.
Those wishing to maintain compatibility of the CP/M file structure, i.e.
to allow modemming ASCII files to or from CP/M systems should follow this
data format:
+ ASCII tabs used (09H); tabs set every 8.
+ Lines terminated by CR/LF (0DH 0AH)
+ End-of-file indicated by ^Z, 1AH. (one or more)
+ Data is variable length, i.e. should be considered a continuous
stream of data bytes, broken into 128-byte chunks purely for the
purpose of transmission.
+ A CP/M "peculiarity": If the data ends exactly on a 128-byte
boundary, i.e. CR in 127, and LF in 128, a subsequent sector
containing the ^Z EOF character(s) is optional, but is preferred.
Some utilities or user programs still do not handle EOF without ^Zs.
+ The last block sent is no different from others, i.e. there is no
"short block".
Figure 7. XMODEM Message Block Level Protocol
Each block of the transfer looks like:
<SOH><blk #><255-blk #><--128 data bytes--><cksum>
in which:
<SOH> = 01 hex
<blk #> = binary number, starts at 01 increments by 1, and
wraps 0FFH to 00H (not to 01)
<255-blk #> = blk # after going thru 8080 "CMA" instr, i.e.
each bit complemented in the 8-bit block number.
Formally, this is the "ones complement".
<cksum> = the sum of the data bytes only. Toss any carry.
Chapter 6 Xmodem Protocol Overview
X/YMODEM Protocol Reference 09-11-86 16
6.3 File Level Protocol
6.3.1 Common_to_Both_Sender_and_Receiver
All errors are retried 10 times. For versions running with an operator
(i.e. NOT with XMODEM), a message is typed after 10 errors asking the
operator whether to "retry or quit".
Some versions of the protocol use <can>, ASCII ^X, to cancel transmission.
This was never adopted as a standard, as having a single "abort" character
makes the transmission susceptible to false termination due to an <ack>
<nak> or <soh> being corrupted into a <can> and aborting transmission.
The protocol may be considered "receiver driven", that is, the sender need
not automatically re-transmit, although it does in the current
implementations.
6.3.2 Receive_Program_Considerations
The receiver has a 10-second timeout. It sends a <nak> every time it
times out. The receiver's first timeout, which sends a <nak>, signals the
transmitter to start. Optionally, the receiver could send a <nak>
immediately, in case the sender was ready. This would save the initial 10
second timeout. However, the receiver MUST continue to timeout every 10
seconds in case the sender wasn't ready.
Once into a receiving a block, the receiver goes into a one-second timeout
for each character and the checksum. If the receiver wishes to <nak> a
block for any reason (invalid header, timeout receiving data), it must
wait for the line to clear. See "programming tips" for ideas
Synchronizing: If a valid block number is received, it will be: 1) the
expected one, in which case everything is fine; or 2) a repeat of the
previously received block. This should be considered OK, and only
indicates that the receivers <ack> got glitched, and the sender re-
transmitted; 3) any other block number indicates a fatal loss of
synchronization, such as the rare case of the sender getting a line-glitch
that looked like an <ack>. Abort the transmission, sending a <can>
6.3.3 Sending_program_considerations
While waiting for transmission to begin, the sender has only a single very
long timeout, say one minute. In the current protocol, the sender has a
10 second timeout before retrying. I suggest NOT doing this, and letting
the protocol be completely receiver-driven. This will be compatible with
existing programs.
When the sender has no more data, it sends an <eot>, and awaits an <ack>,
resending the <eot> if it doesn't get one. Again, the protocol could be
receiver-driven, with the sender only having the high-level 1-minute
timeout to abort.
Chapter 6 Xmodem Protocol Overview
X/YMODEM Protocol Reference 09-11-86 17
Here is a sample of the data flow, sending a 3-block message. It includes
the two most common line hits - a garbaged block, and an <ack> reply
getting garbaged. <xx> represents the checksum byte.
Figure 8. Data flow including Error Recovery
SENDER RECEIVER
times out after 10 seconds,
<--- <nak>
<soh> 01 FE -data- <xx> --->
<--- <ack>
<soh> 02 FD -data- xx ---> (data gets line hit)
<--- <nak>
<soh> 02 FD -data- xx --->
<--- <ack>
<soh> 03 FC -data- xx --->
(ack gets garbaged) <--- <ack>
<soh> 03 FC -data- xx ---> <ack>
<eot> --->
<--- <anything except ack>
<eot> --->
<--- <ack>
(finished)
6.4 Programming Tips
+ The character-receive subroutine should be called with a parameter
specifying the number of seconds to wait. The receiver should first
call it with a time of 10, then <nak> and try again, 10 times.
After receiving the <soh>, the receiver should call the character
receive subroutine with a 1-second timeout, for the remainder of the
message and the <cksum>. Since they are sent as a continuous stream,
timing out of this implies a serious like glitch that caused, say,
127 characters to be seen instead of 128.
+ When the receiver wishes to <nak>, it should call a "PURGE"
subroutine, to wait for the line to clear. Recall the sender tosses
any characters in its UART buffer immediately upon completing sending
a block, to ensure no glitches were mis- interpreted.
The most common technique is for "PURGE" to call the character
receive subroutine, specifying a 1-second timeout,[1] and looping
back to PURGE until a timeout occurs. The <nak> is then sent,
ensuring the other end will see it.
__________
1. These times should be adjusted for use with timesharing systems.
Chapter 6 Xmodem Protocol Overview
X/YMODEM Protocol Reference 09-11-86 18
+ You may wish to add code recommended by John Mahr to your character
receive routine - to set an error flag if the UART shows framing
error, or overrun. This will help catch a few more glitches - the
most common of which is a hit in the high bits of the byte in two
consecutive bytes. The <cksum> comes out OK since counting in 1-byte
produces the same result of adding 80H + 80H as with adding 00H +
00H.
7. XMODEM/CRC Overview
1/13/85 by John Byrns -- CRC option.
Please pass on any reports of errors in this document or suggestions for
improvement to me via Ward's/CBBS at (312) 849-1132, or by voice at (312)
885-1105.
The CRC used in the Modem Protocol is an alternate form of block check
which provides more robust error detection than the original checksum.
Andrew S. Tanenbaum says in his book, Computer Networks, that the CRC-
CCITT used by the Modem Protocol will detect all single and double bit
errors, all errors with an odd number of bits, all burst errors of length
16 or less, 99.997% of 17-bit error bursts, and 99.998% of 18-bit and
longer bursts.
The changes to the Modem Protocol to replace the checksum with the CRC are
straight forward. If that were all that we did we would not be able to
communicate between a program using the old checksum protocol and one
using the new CRC protocol. An initial handshake was added to solve this
problem. The handshake allows a receiving program with CRC capability to
determine whether the sending program supports the CRC option, and to
switch it to CRC mode if it does. This handshake is designed so that it
will work properly with programs which implement only the original
protocol. A description of this handshake is presented in section 10.
Figure 9. Message Block Level Protocol, CRC mode
Each block of the transfer in CRC mode looks like:
<SOH><blk #><255-blk #><--128 data bytes--><CRC hi><CRC lo>
in which:
<SOH> = 01 hex
<blk #> = binary number, starts at 01 increments by 1, and
wraps 0FFH to 00H (not to 01)
<255-blk #> = ones complement of blk #.
<CRC hi> = byte containing the 8 hi order coefficients of the CRC.
<CRC lo> = byte containing the 8 lo order coefficients of the CRC.
Chapter 7 Xmodem Protocol Overview
X/YMODEM Protocol Reference 09-11-86 19
7.1 CRC Calculation
7.1.1 Formal_Definition
To calculate the 16 bit CRC the message bits are considered to be the
coefficients of a polynomial. This message polynomial is first multiplied
by X^16 and then divided by the generator polynomial (X^16 + X^12 + X^5 +
1) using modulo two arithmetic. The remainder left after the division is
the desired CRC. Since a message block in the Modem Protocol is 128 bytes
or 1024 bits, the message polynomial will be of order X^1023. The hi order
bit of the first byte of the message block is the coefficient of X^1023 in
the message polynomial. The lo order bit of the last byte of the message
block is the coefficient of X^0 in the message polynomial.
Figure 10. Example of CRC Calculation written in C
UPDCRC update routine from "rbsb.c". Refer to the source code for these
programs (contained in RZSZ1.SHQ and RZSZ2.SHQ) for usage. A fast table
driven macro is also included in this file.
/* update CRC */
unsigned short
updcrc(c, crc)
register c;
register unsigned crc;
{
register count;
for (count=8; --count>=0;) {
if (crc & 0x8000) {
crc <<= 1;
crc += (((c<<=1) & 0400) != 0);
crc ^= 0x1021;
}
else {
crc <<= 1;
crc += (((c<<=1) & 0400) != 0);
}
}
return crc;
}
7.2 CRC File Level Protocol Changes
7.2.1 Common_to_Both_Sender_and_Receiver
The only change to the File Level Protocol for the CRC option is the
initial handshake which is used to determine if both the sending and the
receiving programs support the CRC mode. All Modem Programs should support
the checksum mode for compatibility with older versions. A receiving
program that wishes to receive in CRC mode implements the mode setting
handshake by sending a <C> in place of the initial <nak>. If the sending
program supports CRC mode it will recognize the <C> and will set itself
into CRC mode, and respond by sending the first block as if a <nak> had
been received. If the sending program does not support CRC mode it will
Chapter 7 Xmodem Protocol Overview
X/YMODEM Protocol Reference 09-11-86 20
not respond to the <C> at all. After the receiver has sent the <C> it will
wait up to 3 seconds for the <soh> that starts the first block. If it
receives a <soh> within 3 seconds it will assume the sender supports CRC
mode and will proceed with the file exchange in CRC mode. If no <soh> is
received within 3 seconds the receiver will switch to checksum mode, send
a <nak>, and proceed in checksum mode. If the receiver wishes to use
checksum mode it should send an initial <nak> and the sending program
should respond to the <nak> as defined in the original Modem Protocol.
After the mode has been set by the initial <C> or <nak> the protocol
follows the original Modem Protocol and is identical whether the checksum
or CRC is being used.
7.2.2 Receive_Program_Considerations
There are at least 4 things that can go wrong with the mode setting
handshake.
1. the initial <C> can be garbled or lost.
2. the initial <soh> can be garbled.
3. the initial <C> can be changed to a <nak>.
4. the initial <nak> from a receiver which wants to receive in checksum
can be changed to a <C>.
The first problem can be solved if the receiver sends a second <C> after
it times out the first time. This process can be repeated several times.
It must not be repeated too many times before sending a <nak> and
switching to checksum mode or a sending program without CRC support may
time out and abort. Repeating the <C> will also fix the second problem if
the sending program cooperates by responding as if a <nak> were received
instead of ignoring the extra <C>.
It is possible to fix problems 3 and 4 but probably not worth the trouble
since they will occur very infrequently. They could be fixed by switching
modes in either the sending or the receiving program after a large number
of successive <nak>s. This solution would risk other problems however.
7.2.3 Sending_Program_Considerations
The sending program should start in the checksum mode. This will insure
compatibility with checksum only receiving programs. Anytime a <C> is
received before the first <nak> or <ack> the sending program should set
itself into CRC mode and respond as if a <nak> were received. The sender
should respond to additional <C>s as if they were <nak>s until the first
<ack> is received. This will assist the receiving program in determining
the correct mode when the <soh> is lost or garbled. After the first <ack>
is received the sending program should ignore <C>s.
Chapter 7 Xmodem Protocol Overview
X/YMODEM Protocol Reference 09-11-86 21
7.3 Data Flow Examples with CRC Option
Here is a data flow example for the case where the receiver requests
transmission in the CRC mode but the sender does not support the CRC
option. This example also includes various transmission errors. <xx>
represents the checksum byte.
Figure 11. Data Flow: Receiver has CRC Option, Sender Doesn't
SENDER RECEIVER
<--- <C>
times out after 3 seconds,
<--- <C>
times out after 3 seconds,
<--- <C>
times out after 3 seconds,
<--- <C>
times out after 3 seconds,
<--- <nak>
<soh> 01 FE -data- <xx> --->
<--- <ack>
<soh> 02 FD -data- <xx> ---> (data gets line hit)
<--- <nak>
<soh> 02 FD -data- <xx> --->
<--- <ack>
<soh> 03 FC -data- <xx> --->
(ack gets garbaged) <--- <ack>
times out after 10 seconds,
<--- <nak>
<soh> 03 FC -data- <xx> --->
<--- <ack>
<eot> --->
<--- <ack>
Here is a data flow example for the case where the receiver requests
transmission in the CRC mode and the sender supports the CRC option. This
example also includes various transmission errors. <xxxx> represents the
2 CRC bytes.
Chapter 7 Xmodem Protocol Overview
X/YMODEM Protocol Reference 09-11-86 22
Figure 12. Receiver and Sender Both have CRC Option
SENDER RECEIVER
<--- <C>
<soh> 01 FE -data- <xxxx> --->
<--- <ack>
<soh> 02 FD -data- <xxxx> ---> (data gets line hit)
<--- <nak>
<soh> 02 FD -data- <xxxx> --->
<--- <ack>
<soh> 03 FC -data- <xxxx> --->
(ack gets garbaged) <--- <ack>
times out after 10 seconds,
<--- <nak>
<soh> 03 FC -data- <xxxx> --->
<--- <ack>
<eot> --->
<--- <ack>
8. MORE INFORMATION
More information may be obtained by calling Telegodzilla at 503-621-3746.
Hit RETURNs for baud rate detection.Speed detection is automatic for 300,
1200, and 2400 bps.
A version this file with boldface, underlining, and superscripts for
printing on Epson or Gemini printers is available on Telegodzilla as
"YMODEME.DOC" or "YMODEME.DQC".
UUCP sites can obtain this file with
uucp omen!/usr/spool/uucppublic/ymodem.doc /tmp
A continually updated list of available files is stored in
/usr/spool/uucppublic/FILES.
The following L.sys line calls Telegodzilla (Pro-YAM in host operation).
Telegodzilla waits for carriage returns to determine the incoming speed.
If none is detected, 1200 bps is assumed and a greeting is displayed.
In response to "Name Please:" uucico gives the Pro-YAM "link" command as a
user name. The password (Giznoid) controls access to the Xenix system
connected to the IBM PC's other serial port. Communications between
Pro-YAM and Xenix use 9600 bps; YAM converts this to the caller's speed.
Finally, the calling uucico logs in as uucp.
omen Any ACU 1200 1-503-621-3746 se:--se: link ord: Giznoid in:--in: uucp
Contact omen!caf if you wish the troff source files.
Chapter 8 Xmodem Protocol Overview
X/YMODEM Protocol Reference 09-11-86 23
9. Document Revisions
The September 11 1986 edition clarifies nomenclature and some minor
points. The April 15 1986 edition clarifies some points concerning CRC
calculations and spaces in the header.
10. YMODEM Programs
A demonstration version of Professional-YAM is available as ZMODEM.ARC
This may be used to test YMODEM amd ZMODEM implementations.
Unix programs supporting the YMODEM protocol are available on Telegodzilla
as RZSZ1.SHQ and RZSZ2.SHQ (SQueezed shell archives). Most Unix like
systems are supported, including V7, Xenix, Sys III, 4.2 BSD, SYS V,
Idris, Coherent, and Regulus.
A version for VAX-VMS is available in VRBSB.SHQ.
Irv Hoff has added YMODEM 1k packets and basic YMODEM batch transfers to
the KMD and IMP series programs, which replace the XMODEM and
MODEM7/MDM7xx series respectively. Overlays are available for a wide
variety of CP/M systems.
Questions about YMODEM, the Professional-YAM communications program, and
requests for evaluation copies may be directed to:
Chuck Forsberg
Omen Technology Inc
17505-V Sauvie Island Road
Portland Oregon 97231
Voice: 503-621-3406
Modem: 503-621-3746 Speed: 2400,1200,300
Usenet: ...!tektronix!reed!omen!caf
Compuserve: 70007,2304
Source: TCE022
Chapter 10 Xmodem Protocol Overview
CONTENTS
1. ROSETTA STONE.................................................... 2
2. YET ANOTHER PROTOCOL?............................................ 2
2.1 Some Messages from the Pioneer.............................. 4
3. XMODEM PROTOCOL ENHANCEMENTS..................................... 5
3.1 Graceful Abort.............................................. 6
3.2 CRC-16 Option............................................... 6
3.3 XMODEM-1k 1024 Byte Packet.................................. 7
4. YMODEM Batch File Transmission................................... 7
4.1 KMD/IMP Exceptions to YMODEM................................ 13
5. YMODEM-g File Transmission....................................... 13
6. XMODEM PROTOCOL OVERVIEW......................................... 14
6.1 Definitions................................................. 14
6.2 Transmission Medium Level Protocol.......................... 15
6.3 File Level Protocol......................................... 16
6.4 Programming Tips............................................ 17
7. XMODEM/CRC Overview.............................................. 18
7.1 CRC Calculation............................................. 19
7.2 CRC File Level Protocol Changes............................. 19
7.3 Data Flow Examples with CRC Option.......................... 21
8. MORE INFORMATION................................................. 22
9. Document Revisions............................................... 23
10. YMODEM Programs.................................................. 23
- i -
LIST OF FIGURES
Figure 1. 1024 byte Packets......................................... 7
Figure 2. Mixed 1024 and 128 byte Packets........................... 7
Figure 3. YMODEM Batch Transmission Session......................... 12
Figure 4. YMODEM Filename packet transmitted by sz.................. 12
Figure 5. YMODEM Header Information used by various programs........ 13
Figure 6. YMODEM-g Transmission Session............................. 14
Figure 7. XMODEM Message Block Level Protocol....................... 15
Figure 8. Data flow including Error Recovery........................ 17
Figure 9. Message Block Level Protocol, CRC mode.................... 18
Figure 10. Example of CRC Calculation written in C................... 19
Figure 11. Data Flow: Receiver has CRC Option, Sender Doesn't........ 21
Figure 12. Receiver and Sender Both have CRC Option.................. 22
- ii -
RZ(1) UNIX Programmer's Manual RZ(1)
NAME
rx, rb, rz - XMODEM, YMODEM, ZMODEM (Batch) file receive
SYNOPSIS
rz [- +1abepqtuvy]
rb [- +1abqtuvy]
rx [- 1abceqtuv] file
gz file ...
[-][v]rzCOMMAND
DESCRIPTION
This program uses error correcting protocols to receive
files over a dial-in serial port from a variety of programs
running under PC-DOS, CP/M, Unix, and other operating sys-
tems. It is invoked from a shell prompt manually, or
automatically as a result of an "sz file ..." command given
to the calling program.
While rz is smart enough to be called from cu(1), very few
versions of cu(1) are smart enough to allow rz to work prop-
erly. Unix flavors of Professional-YAM are available for
such dial-out application.
Rz (Receive ZMODEM) receives files with the ZMODEM batch
protocol. Pathnames are supplied by the sending program,
and directories are made if necessary (and possible). Nor-
mally, the "rz" command is automatically issued by the cal-
ling ZMODEM program, but some defective ZMODEM implementa-
tions may require starting rz the old fashioned way.
Rb receives file(s) with YMODEM, accepting either standard
128 byte sectors or 1024 byte sectors (YAM sb -k option).
The user should determine when the 1024 byte block length
actually improves throughput without causing lost data or
even system crashes.
If True YMODEM (Omen Technology trademark) file information
(file length, etc.) is received, the file length controls
the number of bytes written to the output dataset, and the
modify time and file mode (iff non zero) are set accord-
ingly.
If no True YMODEM file information is received, slashes in
the pathname are changed to underscore, and any trailing
period in the pathname is eliminated. This conversion is
useful for files received from CP/M systems. With YMODEM,
each file name is converted to lower case unless it contains
one or more lower case letters.
Printed 3/29/88 OMEN 1
RZ(1) UNIX Programmer's Manual RZ(1)
Rx receives a single file with XMODEM or XMODEM-1k protocol.
The user should determine when the 1024 byte block length
actually improves throughput without causing problems. The
user must supply the file name to both sending and receiving
programs. Up to 1023 garbage characters may be added to the
received file.
Gz is a shell script which calls sz to command Pro-YAM or
ZCOMM to transmit the specified files. Pathnames used with
gz must be escaped if they have special significance to the
Unix shell.
EXAMPLE: gz "-a C:*.c D:*.h"
Rz may be invoked as rzCOMMAND (with an optional leading -
as generated by login(1)). For each received file, rz will
pipe the file to ``COMMAND filename'' where filename is the
name of the transmitted file with the file contents as stan-
dard input.
Each file transfer is acknowledged when COMMAND exits with 0
status. A non zero exit status terminates transfers.
A typical use for this form is rzrmail which calls rmail(1)
to post mail to the user specified by the transmitted file
name. For example, sending the file "caf" from a PC-DOS
system to rzrmail on a Unix system would result in the con-
tents of the DOS file "caf" being mailed to user "caf".
On some Unix systems, the login directory must contain a
link to COMMAND as login sets SHELL=rsh which disallows
absolute pathnames. If invoked with a leading ``v'', rz
will report progress to /tmp/rzlog. The following entry
works for Unix SYS III/V:
rzrmail::5:1::/bin:/usr/local/rzrmail
If the SHELL environment variable includes rsh or rksh (res-
tricted shell), rz will not accept absolute pathnames or
references to a parent directory, will not modify an exist-
ing file, and removes any files received in error.
If rz is invoked with stdout and stderr to different
datasets, Verbose is set to 2, causing frame by frame pro-
gress reports to stderr. This may be disabled with the q
option.
The meanings of the available options are:
1 Use file descriptor 1 for ioctls and reads (Unix only).
By default, file descriptor 0 is used for ioctls and
reads. This option allows rz to be used with the
Professional-YAM $ command and some versions of ncu(1),
Printed 3/29/88 OMEN 2
RZ(1) UNIX Programmer's Manual RZ(1)
but not cu(1).
a Convert files to Unix conventions by stripping carriage
returns and all characters beginning with the first
Control Z (CP/M end of file).
b Binary (tell it like it is) file transfer override.
c Request 16 bit CRC. XMODEM file transfers default to 8
bit checksum. YMODEM and ZMODEM normally use 16 bit
CRC.
D Output file data to /dev/null; for testing.
e Force sender to escape all control characters; normally
XON, XOFF, DLE, CR-@-CR, and Ctrl-X are escaped.
p (ZMODEM) Protect: skip file if destination file exists.
q Quiet suppresses verbosity.
t tim
Change timeout to tim tenths of seconds.
v Verbose causes a list of file names to be appended to
/tmp/rzlog . More v's generate more output.
y Yes, clobber any existing files with the same name.
EXAMPLES
(Pro-YAM command)
<ALT-2>
Pro-YAM Command: sz *.h *.c
(This automatically invokes rz on the connected system.)
SEE ALSO
ZMODEM.DOC, YMODEM.DOC, IMP(CP/M), Professional-YAM,
sz(omen), usq(omen), undos(omen)
Compile time options required for various operating systems
are described in the source file.
NOTES
Sending serial data to timesharing minicomputers at sus-
tained high speeds has been known to cause lockups, system
halts, kernel panics, and occasional antisocial behaviour.
When experimenting with high speed input to a system, con-
sider rebooting the system if the file transfers are not
successful, especially if the personality of the system
appears altered.
The Unix "ulimit" parameter must be set high enough to per-
mit large file transfers.
The TTY input buffering on some systems may not allow long
blocks or streaming input at high speed. You should suspect
this problem when you can't send data to the Unix system at
high speeds using ZMODEM, YMODEM-1k or XMODEM-1k, when YMO-
DEM with 128 byte blocks works properly. If the system's
tty line handling is really broken, the serial port or the
entire system may not survive the onslaught of long bursts
of high speed data.
Printed 3/29/88 OMEN 3
RZ(1) UNIX Programmer's Manual RZ(1)
The DSZ or Pro-YAM zmodem l numeric parameter may be set to
a value between 64 and 1024 to limit the burst length ("zmo-
dem pl128").
32 bit CRC code courtesy Gary S. Brown. Directory creation
code from John Gilmore's PD TAR program.
BUGS
Calling rz from most versions of cu(1) doesn't work because
cu's receive process fights rz for characters from the
modem.
Programs that do not properly implement the specified file
transfer protocol may cause sz to "hang" the port for a
minute or two. Every reported instance of this problem has
been corrected by using ZCOMM, Pro-YAM, or other program
with a correct implementation of the specified protocol.
Many programs claiming to support YMODEM only support XMODEM
with 1k blocks, and they often don't get that quite right.
Pathnames are restricted to 127 characters. In XMODEM sin-
gle file mode, the pathname given on the command line is
still processed as described above. The ASCII option's
CR/LF to NL translation merely deletes CR's; undos(omen)
performs a more intelligent translation.
VMS VERSION
Some of the #includes with file names enclosed with angle
brackets <> may need to have the angle brackets changed to
"", or vice versa.
The VMS version does not set binary mode according to the
incoming file type. Non binary file processing consists of
stripping all characters beginning with CPMEOF (^Z).
The VMS version does not set the file time.
At high speeds, VMS sometimes loses incoming characters,
resulting in retries and degradation of throughput.
The mysterious VMS C Standard I/O Package and RMS may
interact to modify file contents unexpectedly.
The VMS version does not support invocation as rzCOMMAND .
ZMODEM has not yet been implemented on the VMS version.
ZMODEM CAPABILITIES
Rz supports incoming ZMODEM binary (-b), ASCII (-a), protect
(-p), and append (-+) requests, and ZMODEM command execu-
tion.
Printed 3/29/88 OMEN 4
RZ(1) UNIX Programmer's Manual RZ(1)
FILES
rz.c, rbsb.c, zm.c, zmodem.h source files.
/tmp/rzlog stores debugging output generated with -vv
option.
Printed 3/29/88 OMEN 5
SZ(1) UNIX Programmer's Manual SZ(1)
NAME
sx, sb, sz - XMODEM, YMODEM, ZMODEM file send
SYNOPSIS
sz [-+1abdefkLlNnopqTtuvyY] file ...
sb [-1adfkqtuv] file ...
sx [-1akqtuv] file
sz [-1oqtv] -c COMMAND
sz [-1oqtv] -i COMMAND
sz -TT
DESCRIPTION
Sz uses the ZMODEM, YMODEM or XMODEM error correcting proto-
col to send one or more files over a dial-in serial port to
a variety of programs running under PC-DOS, CP/M, Unix, VMS,
and other operating systems.
While rz is smart enough to be called from cu(1), very few
versions of cu(1) are smart enough to allow sz to work prop-
erly. Unix flavors of Professional-YAM are available for
such dial-out application.
Sz sends one or more files with ZMODEM protocol.
ZMODEM greatly simplifies file transfers compared to XMODEM.
In addition to a friendly user interface, ZMODEM provides
Personal Computer and other users an efficient, accurate,
and robust file transfer method.
ZMODEM provides complete END-TO-END data integrity between
application programs. ZMODEM's 32 bit CRC catches errors
that sneak into even the most advanced networks.
Advanced file management features include AutoDownload
(Automatic file Download initiated without user interven-
tion), Display of individual and total file lengths and
transmission time estimates, Crash Recovery, selective file
transfers, and preservation of exact file date and length.
Output from another program may be piped to sz for transmis-
sion by denoting standard input with "-":
ls -l | sz -
The program output is transmitted with the filename sPID.sz
where PID is the process ID of the sz program. If the
environment variable ONAME is set, that is used instead. In
this case, the Unix command:
ls -l | ONAME=con sz -ay -
will send a "file" to the PC-DOS console display. The -y
option instructs the receiver to open the file for writing
unconditionally. The -a option causes the receiver to con-
vert Unix newlines to PC-DOS carriage returns and linefeeds.
Printed 3/29/88 OMEN 1
SZ(1) UNIX Programmer's Manual SZ(1)
Sb batch sends one or more files with YMODEM or ZMODEM pro-
tocol. The initial ZMODEM initialization is not sent. When
requested by the receiver, sb supports YMODEM-g with
"cbreak" tty mode, XON/XOFF flow control, and interrupt
character set to CAN (^X). YMODEM-g (Professional-YAM g
option) increases throughput over error free channels
(direct connection, X.PC, etc.) by not acknowledging each
transmitted sector.
On Unix systems, additional information about the file is
transmitted. If the receiving program uses this informa-
tion, the transmitted file length controls the exact number
of bytes written to the output dataset, and the modify time
and file mode are set accordingly.
Sx sends a single file with XMODEM or XMODEM-1k protocol
(sometimes incorrectly called "ymodem"). The user must sup-
ply the file name to both sending and receiving programs.
Iff sz is invoked with $SHELL set and iff that variable con-
tains the string rsh or rksh (restricted shell), sz operates
in restricted mode. Restricted mode restricts pathnames to
the current directory and PUBDIR (usually
/usr/spool/uucppublic) and/or subdirectories thereof.
The fourth form sends a single COMMAND to a ZMODEM receiver
for execution. Sz exits with the COMMAND return value. If
COMMAND includes spaces or characters special to the shell,
it must be quoted.
The fifth form sends a single COMMAND to a ZMODEM receiver
for execution. Sz exits as soon as the receiver has
correctly received the command, before it is executed.
The sixth form (sz -TT) attempts to output all 256 code com-
binations to the terminal. In you are having difficulty
sending files, this command lets you see which character
codes are being eaten by the operating system.
If sz is invoked with stdout and stderr to different
datasets, Verbose is set to 2, causing frame by frame pro-
gress reports to stderr. This may be disabled with the q
option.
The meanings of the available options are:
Printed 3/29/88 OMEN 2
SZ(1) UNIX Programmer's Manual SZ(1)
+ Instruct the receiver to append transmitted data to an
existing file (ZMODEM only).
1 Use file descriptor 1 for ioctls and reads. By
default, file descriptor 0 is used. This option allows
sz to be used with the Professional-YAM $ command.
This also works with some versions of ncu(1), but not
cu(1).
a Convert NL characters in the transmitted file to CR/LF.
This is done by the sender for XMODEM and YMODEM, by
the receiver for ZMODEM.
b (ZMODEM) Binary override: transfer file without any
translation.
c COMMAND
Send COMMAND to the receiver for execution, return with
COMMAND's exit status.
d Change all instances of "." to "/" in the transmitted
pathname. Thus, C.omenB0000 (which is unacceptable to
MSDOS or CP/M) is transmitted as C/omenB0000. If the
resultant filename has more than 8 characters in the
stem, a "." is inserted to allow a total of eleven.
e Escape all control characters; normally XON, XOFF, DLE,
CR-@-CR, and Ctrl-X are escaped.
f Send Full pathname. Normally directory prefixes are
stripped from the transmitted filename.
i COMMAND
Send COMMAND to the receiver for execution, return
Immediately upon the receiving program's successful
recption of the command.
k (XMODEM/YMODEM) Send files using 1024 byte blocks
rather than the default 128 byte blocks. 1024 byte
packets speed file transfers at high bit rates. (ZMO-
DEM streams the data for the best possible throughput.)
L N Use ZMODEM sub-packets of length N. A larger N (32 <=
N <= 1024) gives slightly higher throughput, a smaller
N speeds error recovery. The default is 128 below 300
baud, 256 above 300 baud, or 1024 above 2400 baud.
l N Wait for the receiver to acknowledge correct data every
N (32 <= N <= 1024) characters. This may be used to
avoid network overrun when XOFF flow control is lack-
ing.
n (ZMODEM) Send each file if destination file does not
exist. Overwrite destination file if source file is
newer than the destination file.
N (ZMODEM) Send each file if destination file does not
exist. Overwrite destination file if source file is
newer or longer than the destination file.
o (ZMODEM) Disable automatic selection of 32 bit CRC.
p (ZMODEM) Protect existing destination files by skipping
transfer if the destination file exists.
q Quiet suppresses verbosity.
r (ZMODEM) Resume interrupted file transfer. If the
source file is longer than the destination file, the
Printed 3/29/88 OMEN 3
SZ(1) UNIX Programmer's Manual SZ(1)
transfer commences at the offset in the source file
that equals the length of the destination file.
t tim
Change timeout to tim tenths of seconds.
u Unlink the file after successful transmission.
w N Limit the transmit window size to N bytes (ZMODEM).
v Verbose causes a list of file names to be appended to
/tmp/szlog . More v's generate more output.
y Instruct a ZMODEM receiving program to overwrite any
existing file with the same name.
Y Instruct a ZMODEM receiving program to overwrite any
existing file with the same name, and to skip any
source files that do have a file with the same pathname
on the destination system.
EXAMPLES
ZMODEM File Transfer
$ sz -a *.c
This single command transfers all .c files in the current
Unix directory with conversion (-a) to end of line conven-
tions appropriate to the receiving environment. With ZMODEM
AutoDownload enabled, Professional-YAM and ZCOMM will
automatically recieve the files after performing a security
check.
$ sz -Yan *.c *.h
Send only the .c and .h files that exist on both systems,
and are newer on the sending system than the corresponding
version on the receiving system, converting Unix to DOS text
format.
ZMODEM Command Download
cpszall:all
sz -c "c:;cd /yam/dist"
sz -ya $(YD)/*.me
sz -yqb y*.exe
sz -c "cd /yam"
sz -i "!insms"
This Makefile fragment uses sz to issue commands to
Professional-YAM to change current disk and directory.
Next, sz transfers the .me files from the $YD directory,
commanding the receiver to overwrite the old files and to
convert from Unix end of line conventions to PC-DOS conven-
tions. The third line transfers some .exe files. The
fourth and fifth lines command Pro-YAM to change directory
and execute a PC-DOS batch file insms . Since the batch file
takes considerable time, the -i form is used to allow sz to
exit immediately.
XMODEM File Transfer (To Crosstalk)
$ sx -a foo.c
ESC
Printed 3/29/88 OMEN 4
SZ(1) UNIX Programmer's Manual SZ(1)
rx foo.c
The above three commands transfer a single file from Unix to
a PC and Crosstalk with sz translating Unix newlines to DOS
CR/LF. This combination is much slower than ZMODEM.
ERROR MESSAGES
"Caught signal 99" indicates the program was not properly
compiled, refer to "bibi(99)" in rbsb.c for details.
SEE ALSO
rz(omen), ZMODEM.DOC, YMODEM.DOC, Professional-YAM,
IMP(CP/M), sq(omen), todos(omen), tocpm(omen), tomac(omen),
yam(omen)
Compile time options required for various operating systems
are described in the source file.
VMS VERSION
The VMS version does not transmit the file date. The VMS
version calculates the file length by reading the file and
counting the bytes.
The VMS version does not support YMODEM-g or ZMODEM.
When VMS is lightly loaded, the response time may be too
quick for MODEM7 unless the MODEM7 q modifier is used.
The VMS C standard i/o package and RMS sometimes interact to
modify file contents unexpectedly.
FILES
32 bit CRC code courtesy Gary S. Brown.
sz.c, rbsb.c, zm.c, zmodem.h source files
/tmp/szlog stores debugging output (sz -vv)
TESTING FEATURE
The command "sz -T file" exercises the Attn sequence error
recovery by commanding errors with unterminated packets.
The receiving program should complain five times about
binary data packets being too long. Each time sz is inter-
rupted, it should send a ZDATA header followed by another
defective packet. If the receiver does not detect five long
data packets, the Attn sequence is not interrupting the
sender, and the Myattn string in sz.c must be modified.
After 5 packets, sz stops the "transfer" and prints the
total number of characters "sent" (Tcount). The difference
between Tcount and 5120 represents the number of characters
stored in various buffers when the Attn sequence is gen-
erated.
Printed 3/29/88 OMEN 5
SZ(1) UNIX Programmer's Manual SZ(1)
BUGS
Calling sz from most versions of cu(1) doesn't work because
cu's receive process fights sz for characters from the
modem.
Programs that do not properly implement the specified file
transfer protocol may cause sz to "hang" the port for a
minute or two. Every reported instance of this problem has
been corrected by using ZCOMM, Pro-YAM, or other program
with a correct implementation of the specified protocol.
Many programs claiming to support YMODEM only support XMODEM
with 1k blocks, and they often don't get that quite right.
XMODEM transfers add up to 127 garbage bytes per file.
XMODEM-1k and YMODEM-1k transfers use 128 byte blocks to
avoid extra padding.
YMODEM programs use the file length transmitted at the
beginning of the transfer to prune the file to the correct
length; this may cause problems with source files that grow
during the course of the transfer. This problem does not
pertain to ZMODEM transfers, which preserve the exact file
length unconditionally.
Most ZMODEM options are merely passed to the receiving pro-
gram; some do not implement all these options.
Circular buffering and a ZMODEM sliding window should be
used when input is from pipes instead of acknowledging
frames each 1024 bytes. If no files can be opened, sz sends
a ZMODEM command to echo a suitable complaint; perhaps it
should check for the presence of at least one accessible
file before getting hot and bothered. The test mode leaves
a zero length file on the receiving system.
A few high speed modems have a firmware bug that drops char-
acters when the direction of high speed transmissson is
reversed. The environment variable ZNULLS may be used to
specify the number of nulls to send before a ZDATA frame.
Values of 101 for a 4.77 mHz PC and 124 for an AT are typi-
cal.
Printed 3/29/88 OMEN 6